package com.test.controller;

import com.test.representation.OrderRepresentation;
import com.test.service.OrderService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lichangbin@xwbank.com on 2018/7/2
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/orders")
public class OrderController {

  private final OrderService orderService;

  @GetMapping(path = "/{orderNumber}")
  OrderRepresentation getByOrderNumber(@PathVariable("orderNumber") String orderNumber) {
    return orderService.getByOrderNumber(orderNumber);
  }


  @GetMapping
  List<OrderRepresentation> getByUserId(@RequestParam("userId") Long userId) {
    return orderService.getByUserId(userId);
  }

}
